load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library", "rust_test")

package(default_visibility = ["//visibility:public"])

DEPENDENCIES = [
    # Keep sorted.
    "//rs/config",
    "//rs/crypto/node_key_generation",
    "//rs/crypto/node_key_validation",
    "//rs/crypto/test_utils/ni-dkg",
    "//rs/crypto/utils/threshold_sig_der",
    "//rs/interfaces",
    "//rs/interfaces/registry",
    "//rs/interfaces/state_manager",
    "//rs/limits",
    "//rs/monitoring/logger",
    "//rs/monitoring/metrics",
    "//rs/protobuf",
    "//rs/registry/client",
    "//rs/registry/keys",
    "//rs/registry/local_store",
    "//rs/registry/proto_data_provider",
    "//rs/registry/provisional_whitelist",
    "//rs/registry/routing_table",
    "//rs/registry/subnet_features",
    "//rs/registry/subnet_type",
    "//rs/registry/transport",
    "//rs/state_manager",
    "//rs/types/management_canister_types",
    "//rs/types/types",
    "@crate_index//:anyhow",
    "@crate_index//:base64",
    "@crate_index//:clap",
    "@crate_index//:fs_extra",
    "@crate_index//:json5",
    "@crate_index//:maplit",
    "@crate_index//:prost",
    "@crate_index//:rand",
    "@crate_index//:reqwest",
    "@crate_index//:serde",
    "@crate_index//:serde_json",
    "@crate_index//:slog",
    "@crate_index//:tempfile",
    "@crate_index//:thiserror",
    "@crate_index//:url",
    "@crate_index//:x509-cert",
]

MACRO_DEPENDENCIES = []

DEV_DEPENDENCIES = [
    # Keep sorted.
    "@crate_index//:assert_matches",
    "@crate_index//:pretty_assertions",
]

MACRO_DEV_DEPENDENCIES = []

ALIASES = {}

rust_library(
    name = "prep",
    testonly = True,
    srcs = glob(["src/**/*.rs"]),
    aliases = ALIASES,
    crate_name = "ic_prep_lib",
    proc_macro_deps = MACRO_DEPENDENCIES,
    deps = DEPENDENCIES,
)

rust_binary(
    name = "ic-prep",
    testonly = True,
    srcs = ["src/bin/prep.rs"],
    aliases = ALIASES,
    proc_macro_deps = MACRO_DEPENDENCIES,
    deps = DEPENDENCIES + [":prep"],
)

rust_binary(
    name = "ic-principal-id",
    testonly = True,
    srcs = ["src/bin/principal_id.rs"],
    aliases = ALIASES,
    proc_macro_deps = MACRO_DEPENDENCIES,
    deps = DEPENDENCIES + [":prep"],
)

rust_test(
    name = "prep_test",
    aliases = ALIASES,
    crate = ":prep",
    proc_macro_deps = MACRO_DEPENDENCIES + MACRO_DEV_DEPENDENCIES,
    deps = DEPENDENCIES + DEV_DEPENDENCIES,
)

rust_test(
    name = "prep_bin_tests",
    srcs = glob(["src/**/*.rs"]),
    aliases = ALIASES,
    crate_root = "src/bin/prep.rs",
    proc_macro_deps = MACRO_DEPENDENCIES + MACRO_DEV_DEPENDENCIES,
    deps = [":prep"] + DEPENDENCIES + DEV_DEPENDENCIES,
)

# Disabled due to https://github.com/bazelbuild/rules_rust/issues/1233
# rust_doc_test(
#   name = "prep_doc_test",
#   crate = ":prep",
# )
